<?php
$id = $this->id;
$site = $this->site;
?>
<form action="#" method="post" id="delete-site" onsubmit="return deleteSite();">
    <input type="hidden" name="site_id" value="<?php echo $site->site_id; ?>">
    Voulez-vous vraiment effacer le site <b>"<?php echo $site->libelle; ?>"</b> ?<br><br>
    <input type="button" value="Non" class="button" onclick="return $('#grh-dialog').dialog('close');" style="float: right; margin-left: 5px;">
    <input type="submit" name="del" value="Oui" class="button" onclick="return deleteSite();" style="float: right;">
</form>
<script type="text/javascript">
    function deleteSite()
    {
        var urlDel = "<?php echo $this->url('GRH/default', array('controller' => 'site', 'action' => 'delete', 'id' => $site->site_id)); ?>";
        var formData = $("#delete-site").serialize();
        var ajax = $.ajax({
            type: 'post',
            url : urlDel,
            data: formData
        });
        ajax.success(function(data){
            $("#grh-dialog").dialog("close");
            location.reload();
        });
        ajax.error(function(){
            alert("une erreur est survenue");
        });
        return false;
    }
</script>